package cn.heyige.backend.dto;

import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.Valid;
import jakarta.validation.constraints.Max;
import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Size;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

@Data
@AllArgsConstructor
@NoArgsConstructor
@JsonInclude(JsonInclude.Include.NON_NULL)
@Schema(description = "AI解读请求")
public class AiInterpretRequest {
    
    @Schema(description = "占卜记录ID", example = "div_1704096900012")
    private String divinationId;
    
    @NotBlank(message = "卦象编码不能为空")
    @Schema(description = "卦象编码", example = "HUO_TIAN_DA_YOU")
    private String hexagramCode;
    
    @NotBlank(message = "占卜问题不能为空")
    @Size(max = 200, message = "占卜问题不能超过200字符")
    @Schema(description = "占卜问题", example = "今年的事业发展怎么样？")
    private String question;
    
    @Valid
    @Schema(description = "上下文信息")
    private ContextInfo context;
    
    @Schema(description = "AI模型", allowableValues = {"WENXIN", "TONGYI", "CHATGPT"}, example = "WENXIN")
    private String aiModel = "WENXIN";
    
    @Schema(description = "解读等级", allowableValues = {"BASIC", "PROFESSIONAL", "MASTER"}, example = "PROFESSIONAL")
    private String interpretationLevel = "PROFESSIONAL";
    
    @Data
    @AllArgsConstructor
    @NoArgsConstructor
    @Schema(description = "上下文信息")
    public static class ContextInfo {
        @Schema(description = "占卜类型")
        private String divinationType;
        
        @Valid
        @Schema(description = "用户画像")
        private UserProfile userProfile;
        
        @Schema(description = "历史占卜记录")
        private List<PreviousDivination> previousDivinations;
        
        @Data
        @AllArgsConstructor
        @NoArgsConstructor
        @Schema(description = "用户画像")
        public static class UserProfile {
            @Min(1) @Max(120)
            @Schema(description = "年龄", example = "28")
            private Integer age;
            
            @Schema(description = "性别", allowableValues = {"MALE", "FEMALE", "OTHER"})
            private String gender;
            
            @Schema(description = "职业", example = "IT")
            private String occupation;
        }
        
        @Data
        @AllArgsConstructor
        @NoArgsConstructor
        @Schema(description = "历史占卜记录")
        public static class PreviousDivination {
            @Schema(description = "卦象编码")
            private String hexagramCode;
            
            @Schema(description = "问题")
            private String question;
            
            @Schema(description = "日期")
            private String date;
        }
    }
}